class LogManager:
    _instance = None
    _log_widget = None

    @classmethod
    def set_log_widget(cls, widget):
        cls._log_widget = widget

    @classmethod
    def log(cls, message, end="\n"):
        if cls._log_widget:
            cls._log_widget.log(message, end)
            # print(message, end=end)
        else:
            print(message, end=end)  # 如果没有设置 log_widget，则使用普通的 print 